#ifndef AGENT_H
#define AGENT_H

#include "state.h"
#include "state_error.h"
#include "state_idle.h"
#include "state_queue_empty.h"
#include "state_queue_full.h"
#include "state_queue_party_full.h"
#include "state_terminated.h"

#include "../SMTC.h"
#include "../sm_header.h"

class Agent
{
public:
    Agent();
    ~Agent();

private:
    void setSelfState(State *p);

private:
    State *pState;
    STATE_ERROR *pError;
    STATE_IDLE *pIdle;
    STATE_QUEUE_EMPTY *pQueueEmpty;
    STATE_QUEUE_FULL *pQueueFull;
    STATE_QUEUE_PARTY_FULL *pQueuePartyFull;
    STATE_TERMINATED *pTerminated;


    friend class STATE_ERROR;
    friend class STATE_IDLE;
    friend class STATE_QUEUE_EMPTY;
    friend class STATE_QUEUE_FULL;
    friend class STATE_QUEUE_PARTY_FULL;
    friend class STATE_TERMINATED;

public:
    //对状态转移进行检查
    int check_transition_event_initialize();
    int check_transition_event_terminate();
    int check_transition_event_queue();
    int check_transition_event_queue_full();
    int check_transition_event_get_result();
    int check_transition_event_get_result_empty();
    int check_transition_event_error();
    //对状态进行执行
    int perform_transition_event_initialize();
    int perform_transition_event_terminate();
    int perform_transition_event_queue();
    int perform_transition_event_queue_full();
    int perform_transition_event_get_result();
    int perform_transition_event_get_result_empty();
    int perform_transition_event_error();
    //获取当前状态
    int get_current_state(OUT SM_STATE_ENUM *state);
};

#endif // AGENT_H
